﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>




<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>IMES</title>
</head>
<body>
    <div class="layui-panel">
        <div style="padding: 32px;">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="font-weight: bold;float: left;">销售订单</label>
                    <div style="margin-left: 600px;">
                        <input type="text" placeholder="订单编号" id="orderId" style="line-height:25px;">
                        <button class="layui-btn layui-bg-blue" onclick="get()" style="height:29px;line-height:14px">查询</button>
                        <button class="layui-btn" lay-on="test-page-custom" style="height:29px;line-height:14px">新建</button>
                        <button class="layui-btn layui-bg-blue" style="height:29px;line-height:14px" lay-event="edit">编辑</button>
                        <button class="layui-btn layui-bg-red" style="height:29px;line-height:14px" lay-event="delete">删除</button>
                        <button class="layui-btn layui-bg-red" style="height:29px;line-height:14px" onclick="print()">打印</button>
                        <button class="layui-btn layui-btn-primary layui-border-green" style="height:29px;line-height:14px" lay-event="enable">导出</button>
                    </div>
                </div>
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th></th>
                            <th>
                                <input type="checkbox" name="check">
                            </th>
                            <th>时间</th>
                            <th>不良品项编号</th>
                            <th>不良品项名称</th>
                            <th>数量</th>
                            <th>总数量</th>
                            <th>占比</th>
                        </tr>
                    </thead>
                    <tbody id="body">
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-panel" style="margin-top: 20px;">
            <div style="padding: 32px;"></div>
        </div>
    </div>

    <script>
        $(function () {
            getList();
        })
        //销售订单列表显示
        function getList() {
            $.ajax({
                url: '@ViewBag.Darius' + "/api/Defective/GetDefectiveProducts",
                type: "post",
                data: JSON.stringify({
                    defectiveNo: $("#defectiveNo").val() || "",
                }),
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    console.log(res)
                    $(res.data).each(function (i,item) {
                        $("#body").append(`<tr>
                                                      <td>${i+1}</td>
                                                      <td>
                                                           <input type="checkbox" value="${this.defectiveId}" name="check"></input>
                                                      </td>
                                                      <td>${this.createDate}</td>
                                                      <td>${this.defectiveNo}</td>
                                                      <td>${this.defectiveName}</td>                                                     
                                                      <td>${this.count1}</td>
                                                      <td>${res.count}</td>
                                                      <td>${(this.count1*1.0/res.count)*100}%</td>
                                         
                                            </tr>`
                        )
                    })
                }
            })
        }



    </script>
</body>
</html>
